package com.eclipse.e20200128_java8.lambda;

public class Test {
	public static void main(String[] args) {
		//() -> 1:不需要参数,返回值为1
		//需要返回值时 一行语句不用写return
		A a = () -> 1;
		
		//需要返回值时 多行语句要写return
		A a2 = () -> {
			System.out.println("多行语句");
			return 3;
		};
		
		//匿名内部类
		A a1 = new A() {
			public int print() {
				return 2;
			}
		};
		
		System.out.println(a.print());//调用的是() -> 1
		System.out.println(a1.print());
		System.out.println(a2.print());
	}
	
}
interface A{
	//有返回值
	int print();
}